import request from "@/utils/request";
const BASE_URL = "/dept";

const DeptAPI = {
  getList(queryParams: IPageQuery) {
    return request<any, PageResult<IPageVO[]>>({
      url: `${BASE_URL}/list`,
      method: "get",
      params: queryParams,
    });
  },
  getFormData(id: number) {
    return request({
      url: `${BASE_URL}/detail/${id}`,
      method: "get",
    });
  },

  add(data: IForm) {
    return request({
      url: `${BASE_URL}/create`,
      method: "post",
      data: data,
    });
  },

  update(data: IForm) {
    return request({
      url: `${BASE_URL}/update/${data.id}`,
      method: "POST",
      data: data,
    });
  },

  deleteByIds(id: number) {
    return request({
      url: `${BASE_URL}/delete/${id}`,
      method: "get",
    });
  },
};

export default DeptAPI;
export interface IPageVO {
  id: number;
  name: string;
  createAt: Date;
  updatedAt: Date;
}

export interface IPageQuery extends PageQuery {
  name?: string;
}
export interface IForm {
  id?: number;
  name: string;
  sort: number;
}
